package com.jfplugin.mail.mockhttp;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by farmer on 16/8/31.
 *
 * @author 1256810099@qq.com
 */
public class MockHttpServletResponse implements InvocationHandler {

    private final PrintWriter printWriter = new MockPrintWriter(new StringWriter());

    interface MethodName {
        String GET_WRITER = "getWriter";
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) {
        if (MethodName.GET_WRITER.equals(method.getName())) {
            return printWriter;
        }
        return null;
    }

}